在2.0.13与2.1.0或更高版本中,增加了协程短名特性,简化了协程相关API的名称书写。可修改php.ini设置swoole.use_shortname来关闭/开启短名,默认为开启。
go(function () {
co::sleep(0.5);
echo "hello";
});
go("test");
go([$object, "method"]);$c = new chan(1);
$c->push($data);
$c->pop();$redis = new Co\Redis;
$mysql = new Co\MySQL;
$http = new Co\Http\Client;
$tcp = new Co\Client;
$http2 = new Co\Http2\Client;co::sleep(100);
co::fread($fp);
co::gethostbyname('www.baidu.com');defer(function () use ($db) {
$db->close();
});